package cn.linjianhui.flink.sample.util;

import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.java.utils.ParameterTool;
import org.apache.flink.streaming.api.CheckpointingMode;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.connectors.redis.common.config.FlinkJedisPoolConfig;

import java.util.Properties;

public class ParamUtils {
    public static Properties getKafkaConsumerProperty(String[] args, String groupId, String offsetMode) {
        ParameterTool tool = ParameterTool.fromArgs(args);
        Properties props = new Properties();
        props.put("bootstrap.servers", tool.get("bootstrap.servers","192.168.8.251:9092"));
        props.put("group.id", tool.get("group.id", groupId));
        props.put("auto.offset.reset", tool.get("offset", offsetMode));
        return props;
    }

    public static FlinkJedisPoolConfig getJedisPoolConfig(String[] args) {
        FlinkJedisPoolConfig jedisPoolConfig = new FlinkJedisPoolConfig.Builder()
                .setHost("192.168.8.251")
                .setPort(6379)
                .setMaxTotal(12)
                .setTimeout(100000)
                .build();
        return jedisPoolConfig;
    }
}
